package com.itheima.springbootenable;

import com.itheima.config.EnableUser;
import com.itheima.config.MyImportBeanDefinitionRegistrar;
import com.itheima.config.UserConfig;
import com.itheima.domain.Role;
import com.itheima.domain.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import redis.clients.jedis.Jedis;

/**
 * 1.@ComponentScan("com.itheima.config")扫描当前引导类所在包及其子包
 * 2.还可以使用@Import,加载类.这些类都会被spring创建,并放入IOC容器
 * 3.还可以对@Import注解进行封装
 */
@SpringBootApplication
//@ComponentScan("com.itheima.config")  //扫描配置类所在的包,在第三方
//@Import(UserConfig.class)
//@EnableUser
@Import({MyImportBeanDefinitionRegistrar.class})
public class SpringbootEnableApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(SpringbootEnableApplication.class, args);

        //获取Bean
        /*Object user = context.getBean("user");
        System.out.println(user);*/

      /*User user = context.getBean(User.class);
      System.out.println(user);

      Role role = context.getBean(Role.class);
      System.out.println(role);
*/


    }
}

/*Import4种用法
  1.导入bean   @Import(User.class)
  2.导入配置类  @Import(UserConfig.class)
  3.导入ImportSelector的实现类   @Import(MyImportSelector.class)
  4.导入ImportBeanDefinitionRegistrar 的实现类  @Import({MyImportBeanDefinitionRegistrar.class})

* */
